package org.java.energyprofile;

public class JavaLangBenchmark {

	private final int ITERATIONS = 1000;
	private final String someSmalInteger = "5";
	private final String someSmalDouble = "10.0";
	private final String someBigInteger = "2147483647";
	private final String someBigDouble = "2147483647.0";
	private final String someBigLong = "9223372036854775807";
	private final String someBoolean = "true";
	private final String someShortStrng = "short";
	private final String someLongStrng = "zcvzxcasdfqwerweryjhbnmghtyuihgjvbndfghwrtyrughjghjvnmhujkliopyyturtyrtyqweqw qwe wqe fgh rty te";

	public void doBenchmark() throws InterruptedException {
		System.out.println("javaLangBenchmark begin.");
		
		for (int i = 0; i < ITERATIONS; i++) 
			new Boolean(true);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++) 
			new Boolean(someBoolean);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			new Character('a');
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			new Byte((byte)1);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			new Byte(someSmalInteger);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			new Double(0.0);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			new Double(someSmalDouble);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Double.parseDouble(someBigDouble);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			new Float(0.0);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			new Float(someSmalDouble);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			new Integer(1);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			new Integer(someSmalInteger);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Integer.parseInt(someSmalInteger);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Integer.parseInt(someBigInteger);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Long.parseLong(someSmalInteger);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Long.parseLong(someBigLong);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.cbrt(1234.0);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.ceil(1234.1);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.floor(1234.9);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.log(1234.0);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.log10(1234.0);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.pow(2, 2);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.pow(7, 15);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.sqrt(9);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.sqrt(999999);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.round(1.00001);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.round(1.999999);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.sin(2.0);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			Math.cos(2.0);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			System.out.println(someShortStrng);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			System.out.println(someLongStrng);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			System.out.println(2147483647);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			System.out.println(2147483647);
		Thread.sleep(3000);
		
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.split(" ");
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.substring(10);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.charAt(1);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.compareTo(someLongStrng);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.concat(someLongStrng);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.contains("te");
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.endsWith("te");
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.equals(someLongStrng);
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.replace("te", "strings");
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.toUpperCase();
		Thread.sleep(3000);
		
		for (int i = 0; i < ITERATIONS; i++)
			someLongStrng.trim();
		Thread.sleep(3000);
		
		System.out.println("javaLangBenchmark end.");
	}
}
